package com.day05;

/**
 * 数组中的常见异常
 * 1.数组角标越界异常,ArrayIndexOutOfBoundException
 * <p>
 * 2.空指针异常 NullPointerException
 *
 * @author 薛虎
 */
public class ArrayException {
    public static void main(String[] args) {

        //1.数组角标越界异常,ArrayIndexOutOfBoundException
        int[] arr = new int[]{1, 2, 3, 4};
//        for (int i = 0; i <= arr.length; i++) {
//            System.out.println(arr[i]);
//        }

        //2.空指针异常 NullPointerException
        //情况一
        int[] arr1 = new int[]{1, 2, 3};
        arr1 = null;
        System.out.println(arr1[0]);

        //情况二
        int[][] arr2 = new int[4][];
        System.out.println(arr2[0][0]);


    }
}
